<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">
dt {
  font-style: italic;
  margin-top: 15px;
  margin-bottom: 3px;
  margin-left: 0px;
  border-bottom: 1px dotted black;
}
dd {
  margin-left: 10px;
}
table {
  border-collapse:collapse;
  border: 1px solid black;
  margin-top: 7px;
}
th {
  border: 1px solid black;
  padding: 3 7 3 7;
}
td {
  border: 1px solid black;
  padding: 3 7 3 7;
}
</style></head><body><p><a name="jsr"></a><b>jsr</b> :
  jump to subroutine : <a href="opcodes.html">index</a> : <a href="http://asm.objectweb.org/asm40/javadoc/user/org/objectweb/asm/MethodVisitor.html#visitJumpInsn(int,%20org.objectweb.asm.Label)">visitJumpInsn()</a></p><dl><dt>Description</dt><dd>This calls a local subroutine defined within the body of a method. It is
used to implement Java's finally clause.<br></br>jsr first pushes the address (<i xmlns="">pc</i> + 3) onto the operand stack,
where <i xmlns="">pc</i> is the address of this jsr instruction in the
bytecode. The address (<i xmlns="">pc</i> + 3) is  the address of instruction that
immediately follows the jsr instruction in bytecode - it is used  used
by the ret instruction to return from the subroutine. <br></br>Next, execution branches to the address (<i xmlns="">pc</i> + <i xmlns="">branchoffset</i>),
where <i xmlns="">pc</i> is the address of the jsr opcode in the bytecode and
<i xmlns="">branchoffset</i> is the 16-bit signed integer parameter following the
jsr opcode in the bytecode. If you are using Jasmin,
<i xmlns="">branchoffset</i> is computed for you from the address of &lt;label&gt;.</dd><dt>Example</dt><dd><pre>
; This example method uses a PrintMe subroutine to invoke the System.out.println() method.
.method usingSubroutine()V
    ldc "Message 1"
    jsr PrintMe          ; print "Message 1"
    ldc "Message 2"
    jsr PrintMe          ; print "Message 2"
    ldc "Message 3"
    jsr PrintMe          ; print "Message 3"
    return   ; now return from usingSubroutine
; define the PrintMe subroutine ...
PrintMe:       
    astore_1            ; store return-address in local variable 1
    ; call System.out.println()
    getstatic java/lang/System/out Ljava/io/PrintStream;
    invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
    ret 1               ; return to the return-address in local variable 1
.end method
</pre></dd><dt>Notes</dt><dd>1. Addresses are measured in bytes from the start of the bytecode (i.e.
address 0 is the first byte in the bytecode of the currently executing
method).<br></br>2. Subroutines complicate the work of the class file verifier, so extensive use
of subroutines may slow down verification speeds.</dd><dt>See also</dt><dd><a href="ref-jsr_w.html">jsr_w</a> <a href="ref-.html"></a> <a href="ref-ret.html">ret</a> <a href="ref-.html"></a> <a href="ref-goto.html">goto</a> <a href="ref-.html"></a> <a href="ref-goto_w.html">goto_w</a> </dd><dt>Stack</dt><dd><table xmlns="">
<tr>
<td>
<b>Before </b>
</td>
<td><b>After</b></td></tr>
<tr>
<td>...</td>
<td>return-address</td></tr>
<tr>
<td></td>
<td>...</td></tr>
</table></dd><dt>Bytecode</dt><dd><table xmlns="">
<tr>
<td>
<b> Type </b>
</td>
<td><b>Description</b></td></tr>
<tr>
<td>
u1 
</td>
<td>jsr
opcode = 0xA8 (168)
</td></tr>
<tr>
<td>
s2 
</td>
<td><i>branchoffset</i></td></tr>
</table></dd></dl></body></html>